package com.yssoft.service.supervise.enterprise;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.yssoft.mapper.core.TEnterpriseLicenceMapper;
import com.yssoft.mapper.core.TEnterpriseMapper;
import com.yssoft.utils.LayuiUtil;
import com.yssoft.utils.UserHelper;

@Service
public class SuEnterpriseService {

	@Resource
    private TEnterpriseMapper enterpriseMapper;
    @Resource
    private TEnterpriseLicenceMapper enterpriseLicenceMapper;
    
	public JSONObject queryEnterprisePage(int page, int limit, String name, Integer areaId, String isReg) {
		//获取当前登陆账号企业id
        Integer entId =UserHelper.getCurrentCompanyId();//企业id
        PageHelper.startPage(page,limit);//下面第一个查询结果进行分页
        //整理查询条件
        Map<String,Object> param=new HashMap<>();
        //判断是否管理员，查看全部
        param.put("isSystem",1);
        param.put("name", name);
        if(null != areaId && areaId.compareTo(100000) == 0){
        	 param.put("outAreaId", "y");
        }else{
        	 param.put("areaId", areaId);
        }
        param.put("isReg", isReg);
        List<Map<String,Object>> personList = enterpriseMapper.selectAllSql(param);
        //查询条数
        int count = enterpriseMapper.selectCountSql(param);
        JSONObject jsonObject = LayuiUtil.getJSONObjectByMap(personList,count,"","");
		return jsonObject;
	}

}
